/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.murillo.chufa.entry;

import java.lang.ref.ReferenceQueue;

/**
 *
 * @author Administrador
 */
public class CacheEntryFactory<K, V> {

    public static <K, V> CacheEntry<K, V> newCacheEntry(boolean weakKey, K key, V referent, ReferenceQueue queue, ReferenceQueue keyqueue, long creationCost, long tickStamp) {
        if (weakKey) {
            return new org.murillo.chufa.entry.SoftValueWeakKeyCacheEntry<K, V>(key, referent, queue, keyqueue, creationCost, tickStamp);
        } else {
            return new SoftValueCacheEntry<K, V>(key, referent, queue, creationCost, tickStamp);
        }
    }

    public static <K, V> CacheEntry<K, V> newCacheEntry(boolean weakKey, K key, V referent, ReferenceQueue queue, long creationCost, CacheEntry<K, V> old) {
        if (weakKey) {
            return new org.murillo.chufa.entry.SoftValueWeakKeyCacheEntry<K, V>(key, referent, queue, creationCost, (SoftValueWeakKeyCacheEntry) old);
        } else {
            return new SoftValueCacheEntry<K, V>(key, referent, queue, creationCost, (SoftValueCacheEntry) old);
        }
    }

}
